<?php

function https_request($url,$data = null){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)){
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return $output;
}

$access_token = 'y202mf98-LnSRgL7cABMoYfj8bHe47UfZRdJsq1xf0xPtUKpD5Ms3dtw8KGmD-LtHlAE7STE-R2hJTanCprNU6NnqJv9vld6WCUoay8W_ebeN1178IIYXqf-U6oudPRDLMPiAIAABE';
$url = 'https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=';
$url .= $access_token;
$data = '{
     "kf_account" : "hehe@gh_943ac32a80ab",
     "nickname" : "haha",
     "password" : "12345",
}';

$res = https_request($url,$data);

// var_dump($res);
file_put_contents('demo.txt', $res);